Added host.capabilities field.
authorEwan Mellor <ewan@xensource.com>
Sun, 25 Feb 2007 23:37:05 +0000 (23:37 +0000)
committerEwan Mellor <ewan@xensource.com>
Sun, 25 Feb 2007 23:37:05 +0000 (23:37 +0000)
Signed-off-by: Ewan Mellor <ewan@xensource.com>
docs/xen-api/xenapi-datamodel.tex
tools/libxen/include/xen_host.h
tools/libxen/src/xen_host.c
tools/libxen/test/test_bindings.c
tools/python/xen/xend/XendAPI.py
tools/python/xen/xend/XendNode.py

index d7057e1d8c5149b211434dfdb6c35a1d3d8825a9..97cbab514993cf27b2586cda8bf987476174f455 100644 (file)
@@ -4806,6 +4806,7 @@ $\mathit{RO}_\mathit{run}$ &  {\tt API\_version/vendor} & string & identificatio
 $\mathit{RO}_\mathit{run}$ &  {\tt API\_version/vendor\_implementation} & (string $\rightarrow$ string) Map & details of vendor implementation \\
 $\mathit{RO}_\mathit{run}$ &  {\tt software\_version} & (string $\rightarrow$ string) Map & version strings \\
 $\mathit{RW}$ &  {\tt other\_config} & (string $\rightarrow$ string) Map & additional configuration \\
+$\mathit{RO}_\mathit{run}$ &  {\tt capabilities} & string Set & Xen capabilities \\
 $\mathit{RO}_\mathit{run}$ &  {\tt supported\_bootloaders} & string Set & a list of the bootloaders installed on the machine \\
 $\mathit{RO}_\mathit{run}$ &  {\tt resident\_VMs} & (VM ref) Set & list of VMs currently resident on host \\
 $\mathit{RW}$ &  {\tt logging} & (string $\rightarrow$ string) Map & logging configuration \\
@@ -5460,6 +5461,38 @@ void
 
 
 
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_capabilities}
+
+{\bf Overview:} 
+Get the capabilities field of the given host.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} (string Set) get_capabilities (session_id s, host ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt host ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+string Set
+}
+
+
+value of the field
 \vspace{0.3cm}
 \vspace{0.3cm}
 \vspace{0.3cm}
index 8f84dc37adbfb212540ebe2cf8223f9db337523c..f9919ad309efa558a96fb3179b860be1e920b249 100644 (file)
@@ -78,6 +78,7 @@ typedef struct xen_host_record
     xen_string_string_map *api_version_vendor_implementation;
     xen_string_string_map *software_version;
     xen_string_string_map *other_config;
+    struct xen_string_set *capabilities;
     struct xen_string_set *supported_bootloaders;
     struct xen_vm_record_opt_set *resident_vms;
     xen_string_string_map *logging;
@@ -252,6 +253,13 @@ extern bool
 xen_host_get_other_config(xen_session *session, xen_string_string_map **result, xen_host host);
 
 
+/**
+ * Get the capabilities field of the given host.
+ */
+extern bool
+xen_host_get_capabilities(xen_session *session, struct xen_string_set **result, xen_host host);
+
+
 /**
  * Get the supported_bootloaders field of the given host.
  */
index 04b8452e5d6a643450b4bf011f6f3c95f2d3142a..204664ae3c0fe2442826c8bd3fcb7dad85347c91 100644 (file)
@@ -70,6 +70,9 @@ static const struct_member xen_host_record_struct_members[] =
         { .key = "other_config",
           .type = &abstract_type_string_string_map,
           .offset = offsetof(xen_host_record, other_config) },
+        { .key = "capabilities",
+          .type = &abstract_type_string_set,
+          .offset = offsetof(xen_host_record, capabilities) },
         { .key = "supported_bootloaders",
           .type = &abstract_type_string_set,
           .offset = offsetof(xen_host_record, supported_bootloaders) },
@@ -124,6 +127,7 @@ xen_host_record_free(xen_host_record *record)
     xen_string_string_map_free(record->api_version_vendor_implementation);
     xen_string_string_map_free(record->software_version);
     xen_string_string_map_free(record->other_config);
+    xen_string_set_free(record->capabilities);
     xen_string_set_free(record->supported_bootloaders);
     xen_vm_record_opt_set_free(record->resident_vms);
     xen_string_string_map_free(record->logging);
@@ -328,6 +332,23 @@ xen_host_get_other_config(xen_session *session, xen_string_string_map **result,
 }
 
 
+bool
+xen_host_get_capabilities(xen_session *session, struct xen_string_set **result, xen_host host)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = host }
+        };
+
+    abstract_type result_type = abstract_type_string_set;
+
+    *result = NULL;
+    XEN_CALL_("host.get_capabilities");
+    return session->ok;
+}
+
+
 bool
 xen_host_get_supported_bootloaders(xen_session *session, struct xen_string_set **result, xen_host host)
 {
index c76768af157b8de970dfc91ee6091f59fadc2fcb..6a51cd3a058f5b8f569dc602ba8c02b45cd1079e 100644 (file)
@@ -238,6 +238,22 @@ int main(int argc, char **argv)
         return 1;
     }
 
+    xen_string_set *capabilities;
+    if (!xen_host_get_capabilities(session, &capabilities, host))
+    {
+        print_error(session);
+        free(dmesg);
+        xen_string_set_free(supported_bootloaders);
+        xen_string_string_map_free(versions);
+        xen_host_free(host);
+        xen_vm_record_free(vm_record);
+        xen_uuid_bytes_free(vm_uuid_bytes);
+        xen_uuid_free(vm_uuid);
+        xen_vm_free(vm);
+        CLEANUP;
+        return 1;
+    }
+
     printf("%s.\n", vm_uuid);
 
     fprintf(stderr, "In bytes, the VM UUID is ");
@@ -264,6 +280,13 @@ int main(int argc, char **argv)
     }
     printf("\n");
 
+    printf("Host has the following capabilities:");
+    for (size_t i = 0; i < capabilities->size; i++)
+    {
+        printf(" %s", capabilities->contents[i]);
+    }
+    printf("\n");
+
     printf("%s.\n", vm_record->uuid);
 
     printf("Resident on %s.\n", (char *)vm_record->resident_on->u.handle);
@@ -279,6 +302,7 @@ int main(int argc, char **argv)
     xen_string_string_map_free(versions);
     free(dmesg);
     xen_string_set_free(supported_bootloaders);
+    xen_string_set_free(capabilities);
 
     print_vm_metrics(session, vm);
     if (!session->ok)
index abb1118dcdb6fee496ab2c11586fbb8e08fd35fe..fd92d878f3baa15f1fc3a7987211642403269d37 100644 (file)
@@ -630,6 +630,7 @@ class XendAPI(object):
                     'resident_VMs',
                     'host_CPUs',
                     'metrics',
+                    'capabilities',
                     'supported_bootloaders',
                     'API_version_major',
                     'API_version_minor',
@@ -694,6 +695,8 @@ class XendAPI(object):
         return xen_api_success(XendNode.instance().get_host_cpu_refs())
     def host_get_metrics(self, _, ref):
         return xen_api_success(XendNode.instance().host_metrics_uuid)
+    def host_get_capabilities(self, session, host_ref):
+        return xen_api_success(XendNode.instance().get_capabilities())
     def host_get_supported_bootloaders(self, session, host_ref):
         return xen_api_success(['pygrub'])
 
@@ -732,6 +735,7 @@ class XendAPI(object):
                   'resident_VMs': dom.get_domain_refs(),
                   'host_CPUs': node.get_host_cpu_refs(),
                   'metrics': node.host_metrics_uuid,
+                  'capabilities': node.get_capabilities(),
                   'supported_bootloaders': 'pygrub'}
         return xen_api_success(record)
 
index 294959752b5e742fbef9d4a1d604283a750e7073..95068daf9b6ae82f2029a60dc7ce6bfda6e72bc1 100644 (file)
@@ -353,6 +353,9 @@ class XendNode:
     def get_uuid(self):
         return self.uuid
 
+    def get_capabilities(self):
+        return self.xc.xeninfo()['xen_caps'].split(" ")
+
     #
     # Host CPU Functions
     #